<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>后台管理-编辑招聘信息</title>

    <meta name="keywords" content="{$Think.CONFIG.keywords}" />
    <meta name="description" content="{$Think.CONFIG.description}" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

    <include file="Public/head" />
</head>

<body class="no-skin">
<include file="Public/header" />
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

    <include file="Public/sidebar" />
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs" />

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set" />

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="job_name">职位名称 <span class="required">*</span> </label>
                                <div class="col-sm-9">
                                    <input type="text" name='job_name' id='job_name' class="rcol-xs-10 col-sm-5" placeholder="职位名称" value="{$job_info['job_name']}">
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="status">展示状态<span class="required">*</span></label>
                                <div class="col-sm-9">
                                    <select name="status" id="status"  class="col-sm-4 selector" required>
                                        <option value="" >请选择展示状态</option>
                                        <option value="0" <if condition="$job_info['status'] eq 0">selected</if>>不展示</option>
                                        <option value="1" <if condition="$job_info['status'] eq 1">selected</if>>展示</option>
                                    </select>
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="sort">排序 <span class="required">*</span> </label>
                                <div class="col-sm-9">
                                    <input type="text" name="sort" id="sort" placeholder="文章分类排序" class="col-xs-10 col-sm-5" value="{$job_info['sort']}"><span class="required">（默认从小到大排序）</span>
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="job_describe">职位描述</label>
                                <div class="col-sm-6">
                                    <script src="__PUBLIC__/ueditor/ueditor.config.js" type="text/javascript"></script>
                                    <script src="__PUBLIC__/ueditor/ueditor.all.js" type="text/javascript"></script>
                                    <textarea name="job_describe" class="detail" rows="100%" style="width:100%;height:500px;" id="myEditor">{$job_info['job_describe']}</textarea>
                                    <script type="text/javascript">
                                        var editor = new UE.ui.Editor();
                                        editor.render("myEditor");
                                    </script>
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="col-md-offset-2 col-md-9">
                                <input type="hidden" name="job_id" id="job_id" value="{$job_info['job_id']}">
                                <button class="btn btn-info" type="button" onclick='save();'>
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn btn-info" type="button" onclick='fan();'>
                                    <i class="icon-ok bigger-110"></i>
                                    返回
                                </button>
                            </div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer" />

</div><!-- /.main-container -->

<include file="Public/footerjs" />
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script src="__PUBLIC__/qwadmin/js/function.js"></script>
<script type="text/javascript">
    function fan(){
        var urls = "{:U('JobInfo/index')}";
        window.location.href=urls;
    }
    function save(){
        var job_id = $('#job_id').val();
        var job_name = $('#job_name').val();
        var status = $('#status').val();
        var sort = $('#sort').val();
        var detail = editor.getContent();
        var job_describe = encodeURIComponent(detail);
        var urls = "{:U('JobInfo/index')}";
        if(job_name == ''){
            bootbox.dialog({
                title: '友情提示：',
                message: "职位名称必须填写",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }
        if(status == ''){
            bootbox.dialog({
                title: '友情提示：',
                message: "展示状态必须选择",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }

        if(sort == ''){
            bootbox.dialog({
                title: '友情提示：',
                message: "排序必须填写",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }

        $.ajax({
            type: "post",
            url: "{:U('JobInfo/edit')}",
            data: "job_name="+job_name+"&status="+status+"&sort="+sort+"&job_describe="+job_describe+"&job_id="+job_id,
            success: function(data){
                if(data == 1){
                    alert('修改成功！');
                    window.location.href=urls;
                }else{
                    alert('修改失败！');
                }
            }
        });
    }
</script>
</body>
</html>
